#include <iostream>
#include <vector>
using namespace std;

template<typename comparable>
int binarySearch(const vector<comparable> &arrVec, const comparable &value)
{
 int low = 0, hight = arrVec.size() - 1;
 while (low <= hight)
 {
  int mid = (low + hight) / 2;
  if (arrVec[mid] > value)
   hight = mid - 1;
  else
  if (arrVec[mid] < value)
   low = mid + 1;
  else
   return mid;
 }
 return -1;
}

int main()
{
 vector<int> nVec = { 1, 2, 3, 4, 5, 6 };
 cout << binarySearch(nVec, 5);
 return 0;
}